home *** CD-ROM | disk | FTP | other *** search
- ;This is the flash display routine used to display crunched TheDraw image
- ;files. It uses a custom protocol for reproducing a image with any
- ;possible color combinations. The control codes below 32 are reserved
- ;for this function. The following data structure shows the format of a
- ;sequence. Not all operations use the optional bytes <x> or <y>..
- ;
- ;Data Structure: <current byte>[<x>[<y>]]
- ;
- ; 0..15 = New Foreground Color
- ; 16..23 = New Background Color
- ; 24 = Go down to next line, return to same horizontal position as when
- ; routine was started (akin to a c/r).
- ; 25 = Displays <x> number of spaces.
- ; 26 = Displays <x> number of <y>. Also used to display ANY characters
- ; below #32. This function is the only way to do this although it
- ; uses three bytes. Otherwise the code would be interpreted as
- ; another command.
- ; 27 = Toggles on/off the foreground attribute blink flag.
- ;
- ;----------------------------------------------------------------------------
- ;
- ;To use this routine you call the procedure with the ImageData pointed to
- ;by the DS:SI register pair and the display address pointed to by the ES:DI
- ;register pair. The length of the ImageData must be in the CX register.
- ;All used registers are stored on the stack and restored after use.
- ;
- ;Assume we have a ImageData file of a 40 character by 10 line block. Also
- ;the following defintions. ie:
- ;
- ;
- ; ;TheDraw Crunched Asm...etc...Length=467
- ; ImageData DB ...list of image bytes here...
- ;
- ; MOV SI,offset ImageData
- ; MOV AX,0B800H
- ; MOV ES,AX
- ; MOV DI,34*2 + 5*160-162
- ; MOV CX,467
- ; CALL UNCRUNCH
- ;
- ;It is assumed DS points to the segment ImageData resides in. The above
- ;Sets up the ES:DI pair to point to position (34,5) on a color graphics
- ;screen (monochrome users, replace the 0B800H with 0B000H), calculated
- ;as an offset from the start of the screen.
- ;
- ;The value of 467 used is the length of the array as indicated by the title
- ;block provided by TheDraw.
- ;
- ;UnCrunch remembers the horizontal (X) starting position when it goes down
- ;to the next line. This allows you to display the ImageData block correctly
- ;at any position on the screen. ie:
- ;
- ; +-------------------------------------------------+
- ; | |
- ; | | <- Pretend this
- ; | | is the video
- ; | ┌─────────────────────┐ | display.
- ; | │█████████████████████│ |
- ; | │█████████████████████│ |
- ; | │██ ImageData block ██│ |
- ; | │█████████████████████│ |
- ; | │█████████████████████│ |
- ; | │█████████████████████│ |
- ; | └─────────────────────┘ |
- ; | |
- ; | |
- ; | |
- ; +-------------------------------------------------+
- ;
- ;
- ;The ImageData block could just as well have been display in the upper-left
- ;corner of the screen with:
- ; MOV SI,offset ImageData
- ; MOV AX,0B800H
- ; MOV ES,AX
- ; MOV DI,1*2 + 1*160-162
- ; MOV CX,467
- ; CALL UNCRUNCH
- ;
- ;Notice the offset address changed to the coordinates (1,1).
- ;
- ;To display the block in the lower-right corner you would change the MOV DI,
- ;statement to:
- ; MOV DI,40*2 + 15*160-162
- ;
- ;The block is 40 characters wide by 10 lines deep. Therefore to display
- ;such a large block, we must display the block at coordinate (40,15);
- ;
- ;
- ;Obviously I have been attempting to describe this procedure by use of
- ;examples. This was done because I felt it to be the easiest and clearest
- ;way explaining the procedure. It was designed to be as simple as possible,
- ;however for some people the best way to learn it is to experiment. Try
- ;creating a program using the above example information. Use TheDraw to
- ;make a 40 by 10 block (or any size) to experiment with. Good luck. If
- ;you can devise a better way of explaining this, please share your labors
- ;with me. Others will surely benifit. Thanks!
- ;
-
-
- UNCRUNCH PROC NEAR
- ;
- ;Parameters Required:
- ; DS:SI ImageData source pointer.
- ; ES:DI Display address pointer.
- ; CX Length of ImageData source data.
- ;
- PUSH SI ;Save registers.
- PUSH DI
- PUSH AX
- PUSH CX
- PUSH DX
-
- MOV DX,DI ;Save X coordinate for later.
- XOR AX,AX ;Set Current attributes.
-
- LOOPA: LODSB ;Get next character.
- CMP AL,27 ;Does user want to toggle the blink
- JNZ ForeGround ;attibute?
- XOR AH,128 ;Done.
- JMP Short Next
-
- ForeGround:
- CMP AL,16 ;If less than 16, then change the
- JNC BackGround ;foreground color. Otherwise jump.
- AND AH,70H ;Strip off old foreground.
- OR AH,AL
- JMP Short Next
-
- BackGround:
- CMP AL,24 ;If less than 24, then change the
- JZ NextLine ;background color. If exactly 24,
- JNC MultiOutput ;then jump down to next line.
- SUB AL,16 ;Otherwise jump to multiple output
- ADD AL,AL ;routines.
- ADD AL,AL
- ADD AL,AL
- ADD AL,AL
- AND AH,7FH ;Strip off old background.
- OR AH,AL
- JMP Short Next
-
- NextLine:
- ADD DX,160 ;If equal to 24,
- MOV DI,DX ;then jump down to
- JMP Short Next ;the next line.
-
- MultiOutput:
- CMP AL,25 ;If equal to 25,
- JNZ NotMultiSpaces ;then using the
- LODSB ;following code as
- PUSH CX ;a count, output
- XOR CH,CH ;said number of
- MOV CL,AL ;spaces.
- MOV AL,32
- JMP StartOutput ;Use below loop.
-
- NotMultiSpaces:
- CMP AL,26 ;If equal to 26, then using
- JNZ NormalLetter ;the following two codes, display
- LODSB ;<x> number of <y> characters.
- DEC CX ;Adjust main counter.
- PUSH CX ;Display as many of
- XOR CH,CH ;whatever the user
- MOV CL,AL ;wants.
- LODSB ;Get character.
-
- StartOutput:
- JCXZ Stop ;Abort if already at zilch.
- LOOPB: STOSW
- LOOP LOOPB
- Stop: POP CX
- DEC CX ;Adjust main counter.
-
- NormalLetter:
- STOSW ;Save screen letter.
-
- Next: JCXZ Done ;Get next, unless CX
- LOOP LOOPA ;has already one to zero.
-
- Done: POP DX ;Restore registers.
- POP CX
- POP AX
- POP DI
- POP SI
- RET
-
- UNCRUNCH ENDP